﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class VIPInput : MonoBehaviour {

    /// <summary>
    /// 按下(兼容触屏)
    /// </summary>
    /// <param name="button"></param>
    /// <param name="count"></param>
    /// <returns></returns>
    public static bool PressDown(int button, int count = 0)
    {
        if (Input.GetMouseButtonDown(button) || (Input.touchCount > count && Input.GetTouch(button).phase == TouchPhase.Began))
        {
            return true;
        }
        return false;
    }

    /// <summary>
    /// 按下中...(兼容触屏)
    /// </summary>
    /// <param name="button"></param>
    /// <param name="count"></param>
    /// <returns></returns>
    public static bool Press(int button,int count = 0)
    {
        if (Input.GetMouseButton(button) || (Input.touchCount > count && Input.GetTouch(button).phase == TouchPhase.Stationary))
        {
            return true;
        }
        return false;
    }

    /// <summary>
    /// 抬起(兼容触屏)
    /// </summary>
    /// <param name="button"></param>
    /// <param name="count"></param>
    /// <returns></returns>
    public static bool PressUp(int button, int count = 0)
    {
        if (Input.GetMouseButtonUp(button) || (Input.touchCount > count && Input.GetTouch(button).phase == TouchPhase.Ended))
        {
            return true;
        }
        return false;
    }

    /// <summary>
    /// 按下移动
    /// </summary>
    /// <param name="button">第几个手指</param>
    /// <param name="count">几个手指</param>
    /// <returns></returns>
    public static bool PressMove(int button, int count = 0)
    {
        if (Input.touchCount > count && Input.GetTouch(button).phase == TouchPhase.Moved)
        {
            return true;
        }
        return false;
    }

    /// <summary>
    /// 获取触屏参数
    /// </summary>
    /// <param name="count"></param>
    /// <returns></returns>
    public static Touch GetTouch(int count) {
        return Input.GetTouch(count);
    }

}
